package com.zhitong.ztblog.services.servicesImp;

import com.zhitong.ztblog.entity.Sort;
import com.zhitong.ztblog.mappers.SortMapper;
import com.zhitong.ztblog.services.ISortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SortService implements ISortService {
    @Autowired
    private SortMapper sortMapper;

    @Override
    public Sort[] findAll() {
        Sort[] all = sortMapper.findAll();
        return  all;
    }

    @Override
    public Sort findById(int id) {
        Sort sort = sortMapper.findById(id);
        return sort;
    }

    @Override
    public Sort[] findByRand() {
        Sort[] sorts = sortMapper.findByRand();
        return sorts;
    }

    @Override
    public int findSortNum() {
        int num = sortMapper.findSortNum();
        return num;
    }

    @Override
    public void delSortById(int id) {
        sortMapper.delSortById(id);
    }

    @Override
    public void insertSort(Sort sort) {
        sortMapper.insertSort(sort.getName());
    }

    @Override
    public int findSortByName(Sort sort) {
        return sortMapper.findSortByName(sort.getName());
    }

}
